const fs = require('fs')
const path = require('path')

const dotenv = require('dotenv')

// 当调用 config 方法后，process.env 中便多了 .env 文件中定义的常量属性
// 详细见：https://www.npmjs.com/package/dotenv
dotenv.config()

// console.log('process.cwd(): ', process.cwd());

const PRIVATE_KEY = fs.readFileSync(path.resolve(__dirname, './keys/private.key'))
const PUBLIC_KEY = fs.readFileSync(path.resolve(__dirname, './keys/public.key'))


// 这里先解构，然后再导出
module.exports = {
	APP_HOST,
	APP_PORT,
	MYSQL_HOST,
	MYSQL_PORT,
	MYSQL_DATABASE,
	MYSQL_USER,
	MYSQL_PASSWORD,
} = process.env

module.exports.PRIVATE_KEY = PRIVATE_KEY
module.exports.PUBLIC_KEY = PUBLIC_KEY